execute if items entity @s weapon.offhand *[custom_data~{type:"item"}] unless items entity @s weapon.mainhand *[custom_data~{type:"item"}] run tag @s add replace

item replace entity @s[tag=replace] player.cursor from entity @s weapon.mainhand
item replace entity @s[tag=replace] weapon.mainhand from entity @s weapon.offhand
item replace entity @s[tag=replace] weapon.offhand with air

execute unless function vs:chain/can_push if data entity @s SelectedItem.components."minecraft:custom_data".item{chain:true} run return run title @s actionbar [{"text": "当前无法触发效果","color": "red"}]
function vs:item/use/command with entity @s SelectedItem.components."minecraft:custom_data".item
item modify entity @s[gamemode=!creative,tag=!no_consume] weapon.mainhand vs:consume

item replace entity @s[tag=replace] weapon.offhand from entity @s weapon.mainhand
item replace entity @s[tag=replace] weapon.mainhand from entity @s player.cursor
tag @s[tag=replace] remove replace
tag @s[tag=no_consume] remove no_consume